<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>ECharts-title-标题组件</title>
  </head>
  <body>
    <div id="main" style="height: 400px"></div>
    <script src="../libs/echarts-5.3.3.js"></script>
    <script>
      window.onload = function () {
        let myChart = echarts.init(document.getElementById("main"));
        let option = {
          backgroundColor: "rgba(255, 0, 0, 0.1)",
          grid: {
            show: true,
            backgroundColor: "rgba(0, 255, 0, 0.1)",
          },

          // 标题组件
          title: {
            show: true, // 是否显示标题组件
            text: "Echart 5 条形图", // 主标题文本
            left: 20, //  标题组件离容器左侧的距离
            top: 10, // 标题组件离容器上侧的距离
            // 主标题文本样式
            textStyle: {
              color: "red",
              fontSize: 20,
              fontStyle: "italic",
              fontWeight: "bold",
              fontFamily: "Arial",
            },
            subtext: "副标题", // 副标题文本
            // 副标题文本样式
            subtextStyle: {
              color: "blue",
              fontSize: 16,
              fontStyle: "italic",
              fontWeight: "bold",
              fontFamily: "Arial",
            },
            // ...
          },

          xAxis: {
            data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
          },
          yAxis: {},
          series: [
            {
              name: "产品销量柱形图",
              type: "bar",

              data: [5, 20, 36, 10, 10, 20],
            },
          ],
        };
        myChart.setOption(option);
      };
    </script>
  </body>
</html>
